package com.meilai.project.constant;

import com.meilai.project.controller.mini.dto.MiniSimpleObjForSourceDTO;
import lombok.Getter;

import java.math.BigDecimal;
import java.util.List;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.stream.Collectors;

/**
 * @author 张驰
 * @description 小程序-过滤筛选-项目价格区间
 * @date 2022-08-30 11:10
 */
@Getter
public enum MiniSourceBuildingPriceEnum {
    ONE_HALF_TO_TWO(1, "1.5-2万", new BigDecimal("15000"), new BigDecimal("20000"), 1),
    TWO_UP(2, "2万以上", new BigDecimal("20000"), null, 2),
    THREE_UP(3, "3万以上", new BigDecimal("30000"), null, 3);

    private final Integer id;
    private final String name;
    private final BigDecimal min;
    private final BigDecimal max;
    private final Integer sort;

    MiniSourceBuildingPriceEnum(Integer id, String name, BigDecimal min, BigDecimal max, Integer sort) {
        this.id = id;
        this.name = name;
        this.min = min;
        this.max = max;
        this.sort = sort;
    }

    public static List<MiniSimpleObjForSourceDTO> getList(){
        SortedMap<Integer, MiniSourceBuildingPriceEnum> map = new TreeMap<Integer, MiniSourceBuildingPriceEnum>();
        for (MiniSourceBuildingPriceEnum enumObj : MiniSourceBuildingPriceEnum.values()) {
            map.put(enumObj.getSort(), enumObj);
        }
        return map.values().stream().map(d ->
            new MiniSimpleObjForSourceDTO(
                    d.getId().longValue(),
                    d.getName(),
                    MiniSimpleObjForSourceEnum.BUILDING_PRICE.getId(),
                    d.getMin(),
                    d.getMax()
            )
        ).collect(Collectors.toList());
    }
}
